package com.wc.AlgoOJ_homework.ALgoOJ_BL5.H_更小的数;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/4/10 20:03
 * @description http://43.138.190.70:8888/p/LQ1429?tid=66120c2c07c5c018a5dcf262
 */
public class Main {
    static int N = 5010;
    static char[] s;
    // f[i][j] 表示左边界有i，有边界为j是否满足条件
    static boolean[][] f = new boolean[N][N];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = (" " + sc.next()).toCharArray();
        int n = s.length - 1;
        long res = 0;
        for (int len = 2; len <= n; len++) {
            for (int l = 1; l + len - 1 <= n; l++) {
                int r = l + len - 1;
                if (s[l] > s[r]) f[l][r] = true;
                else if (s[l] == s[r]) f[l][r] = f[l + 1][r - 1];
                res += f[l][r] ? 1 : 0;
            }
        }
        System.out.println(res);
    }
}
